using ObjFileLoader.Common;
using ObjFileLoader.Data.DataStore;
using ObjFileLoader.Data.VertexData;
using ObjFileLoader.TypeParsers.Interfaces;

namespace ObjFileLoader.TypeParsers
{
	public class TextureParser : TypeParserBase, ITextureParser, ITypeParser
	{
		private readonly ITextureDataStore _textureDataStore;

		protected override string Keyword => "vt";

		public TextureParser(ITextureDataStore textureDataStore)
		{
			_textureDataStore = textureDataStore;
		}

		public override void Parse(string line)
		{
			string[] array = line.Split(new char[1]
			{
				' '
			});
			float x = array[0].ParseInvariantFloat();
			float y = array[1].ParseInvariantFloat();
			Texture texture = new Texture(x, y);
			_textureDataStore.AddTexture(texture);
		}
	}
}
